<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>安全驾驶培训中心 - 专业驾驶培训咨询</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">


    <style>
/* 导航栏样式开始 */
header {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 1000;
            background-color: white;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }

        .header-container {
            max-width: 900px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px 20px;
        }

        .logo {
            display: flex;
            align-items: center;
        }

        .logo-icon {
            width: 40px;
            height: 40px;
            background-color: #409EFF;
            border-radius: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
            margin-right: 10px;
        }

        .logo-text {
            font-size: 24px;
            font-weight: bold;
            color: #2c3e50;
        }

        .nav-links {
            display: flex;
            list-style: none;
            margin: 0;
            padding: 0;
        }

        .nav-links li {
            margin-left: 20px;
        }

        .nav-links a {
            text-decoration: none;
            color: #34495e;
            font-size: 16px;
            font-weight: 500;
            transition: color 0.3s ease;
            position: relative;
            overflow: hidden;
        }
        
        .nav-links a::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 0;
            height: 0.5px;
            background: #409EFF;
            transition: all 0.3s ease;
        }
        
        .nav-links a:hover {
            color: #409EFF;
        }
        
        .nav-links a:hover::after {
            width: 100%;
        }
        /* 导航栏样式结束 */



        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            line-height: 1.6;
            color: #333;
            background-color: #f0f8ff;
        }

        .header {
            background: linear-gradient(135deg, #1e88e5 0%, #1565c0 100%);
            color: white;
            padding: 20px 0;
            text-align: center;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        .header h1 {
            margin-bottom: 10px;
        }

        .header p {
            color: #e3f2fd;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }

        .section {
            background-color: white;
            border-radius: 8px;
            padding: 30px;
            margin-bottom: 30px;
            box-shadow: 0 2px 10px rgba(30, 136, 229, 0.1);
            border: 1px solid #e3f2fd;
        }

        .section-title {
            color: #1565c0;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 2px solid #bbdefb;
        }

        .features {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }

        .feature-card {
            background-color: #e3f2fd;
            padding: 20px;
            border-radius: 8px;
            text-align: center;
            transition: transform 0.3s ease;
        }

        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 15px rgba(30, 136, 229, 0.2);
        }

        .feature-icon {
            font-size: 2em;
            margin-bottom: 15px;
            color: #1e88e5;
        }

        .courses {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
        }

        .course-card {
            border: 1px solid #bbdefb;
            border-radius: 8px;
            padding: 20px;
            background-color: #fff;
            transition: transform 0.3s ease;
        }

        .course-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 15px rgba(30, 136, 229, 0.2);
        }

        .course-title {
            color: #1565c0;
            margin-bottom: 10px;
            font-weight: bold;
        }

        .course-price {
            color: #1e88e5;
            font-size: 1.2em;
            margin: 10px 0;
            font-weight: bold;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
            color: #1565c0;
        }

        .form-input,
        .form-select,
        .form-textarea {
            width: 100%;
            padding: 10px;
            border: 1px solid #bbdefb;
            border-radius: 4px;
            font-size: 16px;
            transition: border-color 0.3s ease;
        }

        .form-input:focus,
        .form-select:focus,
        .form-textarea:focus {
            outline: none;
            border-color: #1e88e5;
            box-shadow: 0 0 5px rgba(30, 136, 229, 0.2);
        }

        .form-textarea {
            min-height: 100px;
            resize: vertical;
        }

        .submit-btn {
            background: linear-gradient(135deg, #1e88e5 0%, #1565c0 100%);
            color: white;
            padding: 12px 24px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            width: 100%;
            transition: all 0.3s ease;
        }

        .submit-btn:hover {
            background: linear-gradient(135deg, #1976d2 0%, #0d47a1 100%);
            box-shadow: 0 5px 15px rgba(30, 136, 229, 0.3);
        }

        .faq-item {
            margin-bottom: 20px;
        }

        .faq-question {
            font-weight: bold;
            color: #1565c0;
            margin-bottom: 10px;
            cursor: pointer;
            padding: 10px;
            background-color: #e3f2fd;
            border-radius: 4px;
            transition: background-color 0.3s ease;
        }

        .faq-question:hover {
            background-color: #bbdefb;
        }

        .faq-answer {
            color: #666;
            padding: 15px;
            display: none;
            background-color: #f8fdff;
            border-radius: 4px;
            margin-top: 5px;
        }

        .contact-info {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
        }

        .contact-item {
            text-align: center;
            padding: 20px;
            background-color: #e3f2fd;
            border-radius: 8px;
            transition: transform 0.3s ease;
        }

        .contact-item:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 15px rgba(30, 136, 229, 0.2);
        }

        .contact-icon {
            font-size: 2em;
            margin-bottom: 10px;
            color: #1e88e5;
        }

        .map {
            width: 100%;
            height: 300px;
            border: none;
            border-radius: 8px;
            margin-top: 20px;
            box-shadow: 0 2px 10px rgba(30, 136, 229, 0.1);
        }

        ul {
            list-style-type: none;
            padding-left: 0;
        }

        ul li {
            padding: 5px 0;
            position: relative;
            padding-left: 20px;
        }

        ul li:before {
            content: "•";
            color: #1e88e5;
            position: absolute;
            left: 0;
        }

        @media (max-width: 768px) {
            .container {
                padding: 10px;
            }

            .section {
                padding: 20px;
            }

            .features,
            .courses {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>

    <!-- 导航栏 -->
<header>
    <div class="header-container" style="width: 1000px;">
        <div class="logo">
            <div class="logo-icon">
                <i class="fa fa-car text-white text-xl"></i>
            </div>
            <span class="logo-text">安全驾驶培训中心</span>
        </div>
        <nav>
            <ul class="nav-links">
                <a href="/zrz/daohanglanLayui" class="text-dark hover:text-primary nav-link-hover font-medium">首页</a>&nbsp;&nbsp;&nbsp;
                <a href="#courses" class="text-dark hover:text-primary nav-link-hover font-medium">课程</a>&nbsp;&nbsp;&nbsp;
                <a href="/ljk/coach/index" class="text-dark hover:text-primary nav-link-hover font-medium">教练团队</a>&nbsp;&nbsp;&nbsp;
                <a href="/hzj/jiaxiaoguanliList" class="text-dark hover:text-primary nav-link-hover font-medium">基本信息</a>&nbsp;&nbsp;&nbsp;
                <a href="/kaiban/page" class="text-dark hover:text-primary nav-link-hover font-medium">开班信息</a>&nbsp;&nbsp;&nbsp;
                <a href="/zjy/liuyan" class="text-dark hover:text-primary nav-link-hover font-medium">用户留言</a>&nbsp;&nbsp;&nbsp;
                <a href="/zjy/zixun" class="text-dark hover:text-primary nav-link-hover font-medium">用户咨询</a>
            </ul>
        </nav>
        <a href="#" class="contact-button hidden md:block">联系客服</a>
    </div>
</header>
<!--<header class="header">
    <h1>安全驾驶培训中心</h1>
    <p>专业驾驶培训 · 优质教学服务 · 高通过率保障</p>
</header>
!-->
    <div class="container">
        <!-- 驾校特色 -->
        <section class="section">
            <h2 class="section-title">驾校特色</h2>
            <div class="features">
                <div class="feature-card">
                    <div class="feature-icon">🚗</div>
                    <h3>专业教练团队</h3>
                    <p>资深教练，耐心指导，确保学员掌握安全驾驶技能</p>
                </div>
                <div class="feature-card">
                    <div class="feature-icon">📅</div>
                    <h3>灵活课程安排</h3>
                    <p>工作日/周末班，满足不同时间需求</p>
                </div>
                <div class="feature-card">
                    <div class="feature-icon">📱</div>
                    <h3>一对一教学</h3>
                    <p>专属教练指导，针对性训练</p>
                </div>
                <div class="feature-card">
                    <div class="feature-icon">🎯</div>
                    <h3>高通过率</h3>
                    <p>科学训练方法，确保考试通过率</p>
                </div>
            </div>
        </section>

        <!-- 培训课程 -->
        <section class="section">
            <h2 class="section-title">培训课程</h2>
            <div class="courses">
                <div class="course-card">
                    <div class="course-title">C1手动挡课程</div>
                    <p>适合想要掌握完整驾驶技能的学员</p>
                    <ul>
                        <li>完整的驾驶理论培训</li>
                        <li>专业的实践操作指导</li>
                        <li>模拟考试训练</li>
                    </ul>
                    <div class="course-price">￥4980起</div>
                </div>
                <div class="course-card">
                    <div class="course-title">C2自动挡课程</div>
                    <p>适合想要快速掌握驾驶技能的学员</p>
                    <ul>
                        <li>简单易学，上手快</li>
                        <li>针对性实践训练</li>
                        <li>考前集中特训</li>
                    </ul>
                    <div class="course-price">￥5280起</div>
                </div>
                <div class="course-card">
                    <div class="course-title">VIP速成班</div>
                    <p>适合时间紧张需要快速拿证的学员</p>
                    <ul>
                        <li>一对一专属教练</li>
                        <li>优先安排训练时间</li>
                        <li>考试优先安排</li>
                    </ul>
                    <div class="course-price">￥6980起</div>
                </div>
            </div>
        </section>

        <!-- 报名咨询 -->
        <section class="section">
            <h2 class="section-title">报名咨询</h2>
            <form id="consultForm" onsubmit="return submitForm(event)">
                <div class="form-group">
                    <label class="form-label">姓名</label>
                    <input type="text" id="name" name="name" class="form-input" required placeholder="请输入您的姓名">
                </div>
                <div class="form-group">
                    <label class="form-label">手机号码</label>
                    <input type="tel" id="phone" name="phone" class="form-input" required placeholder="请输入您的手机号码">
                </div>
                <div class="form-group">
                    <label class="form-label">意向课程</label>
                    <select id="course" name="course" class="form-select" required>
                        <option value="">请选择课程类型</option>
                        <option value="C1">C1手动挡课程</option>
                        <option value="C2">C2自动挡课程</option>
                        <option value="VIP">VIP速成班</option>
                    </select>
                </div>
                <div class="form-group">
                    <label class="form-label">预计学车时间</label>
                    <select id="time" name="time" class="form-select" required>
                        <option value="">请选择时间</option>
                        <option value="workday">工作日</option>
                        <option value="weekend">双休日</option>
                        <option value="flexible">时间灵活</option>
                    </select>
                </div>
                <div class="form-group">
                    <label class="form-label">咨询内容</label>
                    <textarea id="content" name="content" class="form-textarea" placeholder="请输入您想咨询的具体内容"></textarea>
                </div>
                <button type="submit" class="submit-btn">提交咨询</button>
            </form>
        </section>

        <!-- 咨询列表 -->
        <section class="section">
            <h2 class="section-title">咨询列表</h2>
            <div id="consultList" class="mt-4">
                <!-- 咨询记录将在这里动态显示 -->
                <div class="text-center text-gray-500" id="emptyMessage">暂无咨询记录</div>
            </div>
            
            <!-- 咨询记录模板 -->
            <template id="consultItemTemplate">
                <div class="consult-item bg-blue-50 p-4 rounded-lg mb-4 border border-blue-100">
                    <div class="flex justify-between items-start">
                        <div>
                            <h3 class="font-bold text-blue-800 consult-name"></h3>
                            <p class="text-sm text-gray-600 mb-2">
                                <span class="consult-phone"></span> | 
                                课程: <span class="consult-course"></span> | 
                                时间: <span class="consult-time"></span>
                            </p>
                            <p class="consult-content text-gray-700"></p>
                            <p class="text-xs text-gray-500 mt-2 consult-date"></p>
                        </div>
                        <button class="delete-btn bg-red-500 hover:bg-red-600 text-white px-3 py-1 rounded text-sm transition-colors">
                            删除
                        </button>
                    </div>
                </div>
            </template>
        </section>

        <!-- 常见问题 -->
        <section class="section">
            <h2 class="section-title">常见问题</h2>
            <div class="faq-item"></div>
                <div class="faq-question" onclick="toggleAnswer(this)">
                    Q: 报名需要准备哪些材料？
                </div>
                <div class="faq-answer">
                    A: 需要准备以下材料：<br>
                    1. 身份证原件及复印件<br>
                    2. 体检报告<br>
                    3. 白底证件照片<br>
                    4. 暂住证（非本地户籍）
                </div>
            </div>
            <div class="faq-item">
                <div class="faq-question" onclick="toggleAnswer(this)">
                    Q: 学车需要多长时间？
                </div>
                <div class="faq-answer">
                    A: 一般情况下，从报名到拿证约需3-6个月时间，具体取决于个人学习进度和练习时间的投入。VIP速成班可以缩短至2-3个月。
                </div>
            </div>
            <div class="faq-item">
                <div class="faq-question" onclick="toggleAnswer(this)">
                    Q: 可以分期付款吗？
                </div>
                <div class="faq-answer">
                    A: 是的，我们提供灵活的分期付款方案，可以选择3期、6期、12期分期付款，具体方案可以咨询客服。
                </div>
            </div>
            <div class="faq-item">
                <div class="faq-question" onclick="toggleAnswer(this)">
                    Q: 训练场地在哪里？
                </div>
                <div class="faq-answer">
                    A: 我们在市区有多个训练场地，报名后会根据您的住址就近安排。所有场地都配备标准训练设施，符合考试要求。
                </div>
            </div>
        </section>

        <!-- 联系我们 -->
        <section class="section">
            <h2 class="section-title">联系我们</h2>
            <div class="contact-info">
                <div class="contact-item">
                    <div class="contact-icon">📞</div>
                    <h3>咨询电话</h3>
                    <p>400-888-8888</p>
                </div>
                <div class="contact-item">
                    <div class="contact-icon">📍</div>
                    <h3>地址</h3>
                    <p>城市中心广场A座1楼</p>
                </div>
                <div class="contact-item">
                    <div class="contact-icon">⏰</div>
                    <h3>营业时间</h3>
                    <p>周一至周日 9:00-18:00</p>
                </div>
            </div>
            <iframe class="map" src="https://maps.google.com/maps?q=城市中心广场&output=embed" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>
        </section>
    </div>

    <script>
    // 用于存储咨询记录的key
    const CONSULT_STORAGE_KEY = 'consultRecords';

    // 获取存储的咨询记录
    function getConsultRecords() {
        const records = localStorage.getItem(CONSULT_STORAGE_KEY);
        return records ? JSON.parse(records) : [];
    }

    // 保存咨询记录
    function saveConsultRecords(records) {
        localStorage.setItem(CONSULT_STORAGE_KEY, JSON.stringify(records));
    }

    // 添加新的咨询记录
    function addConsultRecord(record) {
        const records = getConsultRecords();
        records.unshift({
            ...record,
            id: Date.now(), // 使用时间戳作为唯一ID
            date: new Date().toLocaleString()
        });
        saveConsultRecords(records);
        renderConsultList();
        
        // 尝试同步到数据库
        syncToDatabase(record);
    }

    // 尝试同步到数据库
    function syncToDatabase(record) {
        // 构建表单数据
        const formData = new FormData();
        formData.append('name', record.name);
        formData.append('phone', record.phone);
        formData.append('course', record.course);
        formData.append('time', record.time);
        formData.append('content', record.content || '');

        // 发送到后端
        fetch('/zjy/add', {
            method: 'POST',
            body: formData
        })
        .then(response => response.text())
        .then(result => {
            console.log('数据库同步结果:', result);
        })
        .catch(error => {
            console.error('数据库同步失败:', error);
        });
    }

    // 删除咨询记录
    function deleteConsultRecord(id) {
        const records = getConsultRecords();
        const updatedRecords = records.filter(record => record.id !== id);
        saveConsultRecords(updatedRecords);
        renderConsultList();
        
        // 尝试从数据库删除
        try {
            fetch(`/zjy/delete?id=${id}`, {
                method: 'POST'
            });
        } catch (error) {
            console.error('数据库删除失败:', error);
        }
    }

    // 渲染咨询列表
    function renderConsultList() {
        const records = getConsultRecords();
        const consultList = document.getElementById('consultList');
        const emptyMessage = document.getElementById('emptyMessage');
        const template = document.getElementById('consultItemTemplate');

        // 清空现有列表
        while (consultList.firstChild) {
            consultList.removeChild(consultList.firstChild);
        }

        if (records.length === 0) {
            consultList.appendChild(emptyMessage);
            return;
        }

        records.forEach(record => {
            const clone = template.content.cloneNode(true);
            const item = clone.querySelector('.consult-item');
            
            // 填充数据
            item.querySelector('.consult-name').textContent = record.name;
            item.querySelector('.consult-phone').textContent = record.phone;
            item.querySelector('.consult-course').textContent = record.course;
            item.querySelector('.consult-time').textContent = record.time;
            item.querySelector('.consult-content').textContent = record.content || '';
            item.querySelector('.consult-date').textContent = record.date;

            // 添加删除按钮事件
            const deleteBtn = item.querySelector('.delete-btn');
            deleteBtn.onclick = () => {
                if (confirm('确定要删除这条咨询记录吗？')) {
                    deleteConsultRecord(record.id);
                }
            };

            consultList.appendChild(item);
        });
    }

    // 表单提交处理
    function submitForm(event) {
        event.preventDefault();
        const form = event.target;
        
        // 收集表单数据
        const formData = {
            name: form.name.value,
            phone: form.phone.value,
            course: form.course.options[form.course.selectedIndex].text,
            time: form.time.options[form.time.selectedIndex].text,
            content: form.content.value
        };

        // 添加咨询记录
        addConsultRecord(formData);

        // 提示成功并重置表单
        alert('感谢您的咨询，我们会尽快联系您！');
        form.reset();
        return false;
    }

    // 尝试从数据库加载数据
    function loadFromDatabase() {
        fetch('/zjy/zixun')
        .then(response => response.text())
        .then(html => {
            // 如果返回的是HTML页面，我们需要解析出数据
            try {
                // 尝试提取数据，这里假设数据在页面中以某种方式存在
                // 由于我们无法确定具体格式，这里只是一个示例
                console.log('从服务器获取数据成功');
            } catch (error) {
                console.error('解析服务器数据失败:', error);
            }
        })
        .catch(error => {
            console.error('从服务器加载数据失败:', error);
        });
    }

    // 页面加载时渲染咨询列表
    document.addEventListener('DOMContentLoaded', function() {
        renderConsultList();
        loadFromDatabase();
        
        // FAQ切换显示
        window.toggleAnswer = function(element) {
            const answer = element.nextElementSibling;
            const isHidden = answer.style.display === 'none' || answer.style.display === '';
            answer.style.display = isHidden ? 'block' : 'none';
        };

        // 导航栏滚动效果
        window.addEventListener('scroll', function() {
            const header = document.querySelector('header');
            if (window.scrollY > 50) {
                header.classList.add('shadow-md');
                header.style.padding = '10px 0';
            } else {
                header.classList.remove('shadow-md');
                header.style.padding = '15px 0';
            }
        });
    });
</script>
</body>
</html>